using System;
using System.Collections.Generic;
using System.Data;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Mod.Training {
    public class Migrations : DataMigrationImpl {

        public int Create() {
			// Creating table ItemListPartRecord
			SchemaBuilder.CreateTable("ItemListPartRecord", table => table
				.ContentPartRecord()
			);

            ContentDefinitionManager.AlterPartDefinition("ItemListPart", cfg => cfg.Attachable());

            return 1;
        }

        public int UpdateFrom1()
        {
            SchemaBuilder.CreateTable("Item", table => table
                .Column<int>("Id", c => c.PrimaryKey().Identity())
                .Column<string>("Name")
                .Column<string>("Age")
                .Column<int>("ItemListPartRecord_id")
            );

            return 2;
        }
    }
}